import hilog from '@ohos.hilog';
import prompt from '@ohos.prompt';

export default class Utils {

    /**
     * 封装提示打印
     * @param str
     */
    myLog(info: String) {
        hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.INFO);
        hilog.info(0x0000, 'testTag', '%{public}s', info);
    }

    /**
     * 封装警告打印
     * @param str
     */
    myWarnLog(warn: String) {
        hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.WARN);
        hilog.warn(0x0000, 'testTag', 'Failed Cause: %{public}s', warn);
    }

    /**
     * 封装错误打印
     * @param str
     */
    myErrLog(err: String) {
        hilog.isLoggable(0x0000, 'testTag', hilog.LogLevel.ERROR);
        hilog.error(0x0000, 'testTag', 'Failed Cause: %{public}s', err);
    }

    /**
     * 封装Toast提示
     * @param info
     */
    showInfo(info) {
        prompt.showToast({
            message: info,
            duration: 2000
        })
    }
}